<%@ page import = "java.io.*" %>
<%@ page import = "java.net.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "java.util.*" %>
<%@ page import="com.mbbcpa.app.manager.*" %>
<%@ page import="com.mbbcpa.app.EncryptionHelper" %>
<%@ page import="com.mbbcpa.app.EbppKeys" %>
<%@ page import="com.mbbcpa.util.*" %>
<%@ page import="com.mbbcpa.security.dao.*" %>


<html>
<head>
<link rel="stylesheet" href="resource/mbb_sec_global.css" type="text/css" />
<SCRIPT LANGUAGE="JavaScript1.2">
	
</SCRIPT>
</head>
<%
	ArrayList arlSecGroupList = new ArrayList();
	ArrayList arlSecSubGroupList = new ArrayList();
	ArrayList arlSecAccessRightList = new ArrayList();
	ArrayList arlSecUserList = new ArrayList();
	ArrayList userid = new ArrayList();
	
	arlSecGroupList = (ArrayList) session.getAttribute(Constants.SECURITY_GROUP);
	arlSecSubGroupList = (ArrayList) session.getAttribute(Constants.SECURITY_SUB_GROUP_LIST);
	arlSecAccessRightList = (ArrayList) session.getAttribute(Constants.SECURITY_ACCESS_RIGHT_LIST);
	arlSecUserList = (ArrayList) session.getAttribute(Constants.SECURITY_USERS_LIST);
%>


<BR>
<BR>
<BR>
		<table align="center" border=0 width = 70%>
			<tr>
				<th class="pageTitle" colspan="2">Security List</th>
			</tr>
			<tr>
				<th class="header mbb_blue" colspan="2" align="center">Security module - Security List</th>
			</tr>
			<tr class="header">
				<td colspan = "2"></td>
			</tr>
  		</table>
<BR>
<% for(int i = 0; i < arlSecGroupList.size(); i++){ 
		
		ArrayList arlTempSecSubGroupList = new ArrayList();
%>
		
		<table align="center" class="tabularData" width=70% border="0" rules="cols">
			<thead class="th1">
				<tr>
					<th colspan="4">
						<div style="FONT-SIZE: 14px" align="left">
							<h2>Security Group <%=i+1%> </h2>
						</div>
					</th>
			</thead>
			<%
				String row = "";
				int result;
					result = (i + arlSecGroupList.size()) % 2;
		
					if(result==0)
					{
						row="even";
					}
					else
					{
						row="alt";
					}
		
					SecGroupsDao secgroupDao = (SecGroupsDao) arlSecGroupList.get(i);
			%>
			<tr class="even" >
				<td width="20%" style="BACKGROUND: #e3e3e3; TEXT-ALIGN: center; FONT-SIZE: 11px;"><strong>Group Code:</strong>&nbsp;&nbsp;&nbsp;<%=secgroupDao.getGroupName()%></td>
				<td width="20%" style="BACKGROUND: #e3e3e3; TEXT-ALIGN: center; FONT-SIZE: 11px;"><strong>Group Name:</strong>&nbsp;&nbsp;&nbsp;<%=secgroupDao.getGroupCode()%></td>
			</tr>
		</table>
		
		<table align="center" class="tabularData" width=70% border="0" rules="cols">
			<thead class="th1">
				<tr>
					<th colspan="4">
						<div class="sectionTableTitle">
							<h2>Security Group Level</h2>
						</div>
					</th>
			</thead>
			<tr class="headerD" style="border: thin solid">
				<td width="40%" class="center_note">Child Group Code</td>
				<td width="40%" class="center_note">Child Group Name</td>
			</tr>
			<% for(int j = 0; j < arlSecSubGroupList.size(); j++){
				
				String row2 = "";
				int result2;
					result2 = (j + arlSecSubGroupList.size()) % 2;
		
					if(result2==0)
					{
						row2="even";
					}
					else
					{
						row2="alt";
					}
					SecGroupLevelDao secGroupLevelDao = (SecGroupLevelDao) arlSecSubGroupList.get(j);
					if(secGroupLevelDao.getPGroupCode().equals(secgroupDao.getGroupCode())){
					arlTempSecSubGroupList.add(secGroupLevelDao.getcGroupCode());
			%>
			<tr class="<%=row2%>" >
				<td width="40%" class="center_note"><%=secGroupLevelDao.getcGroupCode()%></td>
				<td width="40%" class="center_note"><%=secGroupLevelDao.getChildGroupName()%></td>
			</tr>
			<%}} %>	
		</table>		
		
		<table align="center" class="tabularData" width=70% border="0" rules="cols">
			<thead class="th1">
				<tr>
					<th colspan="4">
						<div class="sectionTableTitle">
							<h2>Security Access Rights</h2>
						</div>
					</th>
			</thead>
			<tr class="headerD" style="border: thin solid">
				<td width="30%" class="center_note">Module Code - Module Name</td>
				<td width="20%" class="center_note">Read Access</td>
				<td width="20%" class="center_note">Update Access</td>
				<td width="20%" class="center_note">Insert / Delete Access</td>
			</tr>
			<% for(int k = 0; k < arlSecAccessRightList.size(); k++){
				
				String row3 = "";
				int result3;
					result3 = (k + arlSecAccessRightList.size()) % 2;
		
					if(result3==0)
					{
						row3="even";
					}
					else
					{
						row3="alt";
					}
					SecAccessDao secaccessDao = (SecAccessDao) arlSecAccessRightList.get(k);
					if(secaccessDao.getGroupCode().equals(secgroupDao.getGroupCode())){
			%>
			<tr class="<%=row3%>" >
				<td width="30%" class="center_note"><%=secaccessDao.getModuleCode()%> - <%=secaccessDao.getModuleName()%></td>
				<td width="20%" class="center_note">
<%
				if(secaccessDao.getReadFlag().equals(Constants.SECURITY_CODE_NO)){
%>
				<%=Constants.SECURITY_VALUE_NO%>
<%
				}else{
%>
				<%=Constants.SECURITY_VALUE_YES%>
<%				}
%>
				</td>
				<td width="20%" class="center_note">
<%
				if(secaccessDao.getUpdateFlag().equals(Constants.SECURITY_CODE_NO)){
%>
				<%=Constants.SECURITY_VALUE_NO%>
<%
				}else{
%>
				<%=Constants.SECURITY_VALUE_YES%>
<%				}
%>				</td>
				<td width="20%" class="center_note">
<%
				if(secaccessDao.getWriteFlag().equals(Constants.SECURITY_CODE_NO)){
%>
				<%=Constants.SECURITY_VALUE_NO%>
<%
				}else{
%>
				<%=Constants.SECURITY_VALUE_YES%>
<%				}
%>				</td>
			</tr>
			<%}} %>
		</table>	
				
		<table align="center" class="tabularData" width=70% border="0" rules="cols">
			<thead class="th1">
				<tr>
					<th colspan="4">
						<div class="sectionTableTitle">
							<h2>Security User List</h2>
						</div>
					</th>
			</thead>
			<tr class="headerD" style="border: thin solid">
				<td width="40%" class="center_note">User ID</td>
				<td width="40%" class="center_note">User Name</td>
			</tr>
			<%  ArrayList al = new ArrayList();
				ArrayList ar = new ArrayList();
				Map loginmap = new HashMap();
				for(int l = 0; l < arlSecUserList.size(); l++){ 

				String row4 = "";
				int result4;
					result4 = (l + arlSecUserList.size()) % 2;
					if(result4==0)
					{
						row4="even";
					}
					else
					{
						row4="alt";
					}
					SecUserDao secuserdao = (SecUserDao) arlSecUserList.get(l);
					
					for(int n = 0; n < arlTempSecSubGroupList.size(); n++) {
					
					if(secuserdao.getPGroupname().equals(secgroupDao.getGroupCode())){	
					if(secuserdao.getGroupCode().equals(arlTempSecSubGroupList.get(n))){
						
					loginmap.put(secuserdao.getLogonId(), secuserdao.getUserName());
		%>			
			<!--  <tr class="<%=row4%>" >
				 <td width="40%" class="center_note"><%=secuserdao.getLogonId()%></td>
				<td width="40%" class="center_note"><%=secuserdao.getUserName()%></td>
			</tr>  -->
			<%}} }}%>
			
				<% Iterator iter = loginmap.entrySet().iterator(); %>
				<%while (iter.hasNext()) {  
						Map.Entry mEntry = (Map.Entry) iter.next();
						System.out.println(mEntry.getKey() + " : " + mEntry.getValue()); %>
						
			 <tr ><td width="40%" class="center_note"><%=mEntry.getKey()%></td>
				  <td width="40%" class="center_note"><%=mEntry.getValue()%></td>
			 </tr> 
				<%} System.out.println("***********");%>
						
						
</table>
		<br>
		<table border="0" cellpadding="0" cellspacing="0" width="70%" align="center">
			<tr>
				<td width="80%" height="1" style="border-bottom: 1px solid">&nbsp;</td>
			</tr>
		</table>
		<br>
		<br>
<%} %>

</body>
</html>